<?php
if (!defined('MVC_ROOT_DIR'))  die('Hacking attempt');
include MVC_ROOT_DIR.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.MVC_LIB_DIR.'CheckRun.php';
//加载系统配置文件
$systemSetting = parse_ini_file(MVC_ROOT_DIR.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'setting.inc',true);
//如果开启伪静态规则
if($systemSetting['url']['static']=='1'){
	include  MVC_ROOT_DIR.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.MVC_LIB_DIR.'Static.php';				
}
//如果开启文件缓存机制
if ($systemSetting['cache']['fileCache']==1 ){
	$cacheFileDir=MVC_CACHE_DIR.'file'.DIRECTORY_SEPARATOR;
	$cacheFileName = str_replace('%','%%',$cacheFileDir.urlencode($_SERVER['REQUEST_URI']).'.html');
	//如果缓存文件没过期则载入文件
	if (file_exists($cacheFileName) and (filemtime($cacheFileName)+$systemSetting['cache']['cacheTime'])>time() or $systemSetting['cache']['cacheTime']==0){		
		echo file_get_contents($cacheFileName);
	}else{//否则重新生成文件并删除过期文件
		//MVC主类
		include  MVC_ROOT_DIR.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.MVC_LIB_DIR.'Actions.class.php';
		//初始化文件
		include MVC_ROOT_DIR.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.MVC_LIB_DIR.'Init.php';
		//启动主程序
		Actions::run();
		Actions::thisActionCache($cacheFileDir,$cacheFileName,$systemSetting['cache']['cacheTime']);		
	}
}else{
	error_reporting(MVC_DEBUG);
	//MVC主类
	include  MVC_ROOT_DIR.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.MVC_LIB_DIR.'Actions.class.php';
	//初始化文件
	include MVC_ROOT_DIR.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.MVC_LIB_DIR.'Init.php';
	//启动主程序
	Actions::run();
}